

			//// FINAL TOUCHES: CONSTRUCTION, IMPUTATION & LABELING ////


	// c. IMPUTATION
		// o. For variables that we are going to use for heterogeneity analysis, we want to save versions of the variables without imputations
			foreach x in fam_asb_b cognitive_score_b ef_score_b timedecl_b riskdecl_b personalitystd_b sctp_b {
				qui gen `x'_noimp = `x'
				la var `x'_noimp "`:var la `x'' (no imputation)"
			}
		// i. For missing observations within phase, we take the phase median
			forvalues i = 1(1)3 {
				foreach x in $base mentalhealth_z_b success_b fam_asb_b personalitystd_b total7da_zero_b savstock_100p99_b {
					if "`x'"!="timedecl_b" & "`x'"!="riskdecl_b" & "`x'"!="cognitive_score_b" & "`x'"!="ef_score_b" {
						qui sum `x' if p`i'==1, d
						qui replace `x' = round(r(p50)) if (`x' ==.| `x'==.r |`x'==.d) & p`i'==1
					}
				}
			}

		// ii. For observations missing for the entire phase, we take the sample median
				foreach x in $base  disputes_all_b disputes_all_z_b cens_disputes_all_b cens_disputes_all_z_b mentalhealth_z_b success_b fam_asb_b personalitystd_b total7da_zero_b savstock_100p99_b {
					if "`x'"!="timedecl_b" & "`x'"!="riskdecl_b" & "`x'"!="cognitive_score_b" & "`x'"!="ef_score_b" {
						qui sum `x', d
						qui replace `x' = round(r(p50)) if (`x' ==.| `x'==.r |`x'==.d)
					}
				}

	// d. INVERSE HYPERBOLIC SINE TRANSFORMATIONS

			foreach x in e {

				foreach y in profitsump99avg7d {
						local lab : var label `y'_`x'
						qui gen `y'hst_`x' = ln(`y'_`x'+((`y'_`x'^2)+1)^.5)
						qui la var `y'hst_`x' "Hst: `lab'"
					}
				}

			foreach x in b {

				foreach y in cashsumprofit4w  {
						local lab : var label `y'_`x'
						qui gen `y'hst_`x' = ln(`y'_`x'+((`y'_`x'^2)+1)^.5)
						qui la var `y'hst_`x' "Hst: `lab'"
					}
				}

	// e. Log transformations

			foreach x in b e {

				foreach y in savstock {

					local lab: var label `y'_`x'
					qui gen `y'log_`x' = ln(1+ `y'_`x')
					qui la var `y'log_`x' "Log: `lab'"
					}
				}

			foreach x in e {

				foreach y in cshealthedu2wusd csfood3dusd csnonfood2wusd cstot2wusd bizexptot bizstocktot profitsumavg7d {

					local lab: var label `y'_`x'
					qui gen `y'log_`x' = ln(1+ `y'_`x')
					qui la var `y'log_`x' "Log: `lab'"
					}
				}

			foreach x in b {

               foreach y in cashsumprofit4w {

					local lab: var label `y'_`x'
					qui gen `y'log_`x' = ln(1+ `y'_`x')
					qui la var `y'log_`x' "Log: `lab'"
					}
				}

			**Shorten variable names
	qui gen time_saveproblems_rescz_e= time_decl_saveproblems_rescz_e
	qui gen time_saveproblems_rescz_b= time_decl_saveproblems_rescz_b
